package com.mzkj.wanjulaile.mobile.api.modules.account.controller;

import com.mzkj.wanjulaile.mobile.api.common.controller.BaseController;
import com.mzkj.wanjulaile.mobile.api.common.entity.ResultEntity;
import com.mzkj.wanjulaile.mobile.api.modules.account.entity.Account;
import com.mzkj.wanjulaile.mobile.api.modules.account.service.AccountService;
import com.mzkj.wanjulaile.mobile.api.modules.sys.common.ResultMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * 账户控制类
 * Created by wangxw on 2016/12/12.
 */
@Controller
@RequestMapping("/mobile/toy")
public class AccountController extends BaseController {

    @Autowired
    private AccountService accountService;

    //获取个人信息
    @RequestMapping(value = "getAccount")
    @ResponseBody
    public ResultMessage<Account> getAccount(String openid) {
        ResultMessage<Account> result = new ResultMessage<Account>();
        try {
            Account account = accountService.findAccountByOpenid(openid);
            accountService.calTotalDeposit(account);
            account.setPassword("");
            result.setResultObject(account);
//            result.setStatusCode(WXConstant.STATUS_CODE_SUCCESS);
            result.setStatusMsg("");
        } catch (Exception e) {
            e.printStackTrace();
//            result.setStatusCode(WXConstant.STATUS_CODE_FAILED);
            result.setStatusMsg("获取数据失败");
        }
        return result;
    }

}
